﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Singer.Shared.Models
{
    public class QueryResult<T>
    {
        /// <summary>
        /// 当前页码
        /// </summary>
        public int PageNo { get; set; }
        /// <summary>
        /// 分页大小
        /// </summary>
        public int PageSize { get; set; }
        /// <summary>
        /// 数据总数
        /// </summary>
        public int TotalCount { get; set; }
        /// <summary>
        /// 总页数
        /// </summary>
        public int PageCount { get; set; }
        /// <summary>
        /// 数据集合
        /// </summary>
        public List<T> List { get; set; } = new List<T>();

        public QueryResult(List<T> list, int pageNo, int pageSize, int totalCount)
        {
            List = list;
            PageNo = pageNo;
            PageSize = pageSize;
            TotalCount = totalCount;
            PageCount = pageSize <= 0 ? 0 : (int)Math.Ceiling((double)totalCount / pageSize);
        }
    }
}
